import http from "@/api";
import { ResPage } from "../interface";
import { Album, Photo } from "../interface/album";

/**
 * @name 相册模块
 */

export const getAlbumListApi = (pageNum: number, pageSize: number, wrapper?: Partial<Album>) => {
	return http.post<ResPage<Album>>(`/album/getList/${pageNum}/${pageSize}`, { wrapper });
};

export const addAlbumApi = (album: Album) => {
	return http.post<string>("/album/create", album);
};

export const updateAlbumApi = (album: Partial<Album>) => {
	return http.post<string>("/album/update", album);
};

export const deleteAlbumApi = (id: number) => {
	return http.delete<string>(`/album/delete/${id}`);
};

export const getPhotoListApi = (albumId: number, pageNum: number, pageSize: number) => {
	return http.get<ResPage<Photo>>(`/photo/getList/${albumId}/${pageNum}/${pageSize}`);
};

export const addPhotoApi = (id: number, photos: Partial<Photo>[]) => {
	return http.post<string>(`/photo/create/${id}`, { photo: photos });
};

export const updatePhotoApi = (photo: Partial<Photo>) => {
	return http.post<string>("/photo/update", photo);
};

export const deletePhotoApi = (idArr: number[]) => {
	return http.post<string>(`/photo/delete`, { photo_id: idArr });
};
